#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<assert.h>
#include<malloc.h>
typedef int DataType;
typedef struct SLNode
{
	struct SLNode* next;
	DataType a;
}SLNode;
SLNode* Initial()
{
	SLNode* newhead = (SLNode*)malloc(sizeof(SLNode));
	newhead->a = 0;
	newhead->next = NULL;
	return newhead;
}
void PushBackSL(SLNode* head,DataType n)
{
	assert(head);
	SLNode* newp = (SLNode*)malloc(sizeof(SLNode));
	newp->a = n;
	newp->next = NULL;
	while (head->next)
	{
		head = head->next;
	}
	head->next = newp;
}
void Swap(SLNode* head)
{
	SLNode* newhead = head;
	while (head->next)
	{
		SLNode* the_new = head->next;
		SLNode* the_next = newhead;
		while (the_next->next->next)
		{
			the_next = the_next->next;
		}
		if (head != the_next)
		{
			head->next = the_next->next;
			the_next->next = NULL;
			head->next->next = the_new;
		}
		head = the_new;

	}
}
int main()
{
	SLNode* head = Initial();
	while (1)
	{
		int n = 0;
		scanf("%d", &n);
		if (n == 0)
			break;
		PushBackSL(head, n);
	}
	Swap(head->next);
	head=head->next;
	while (head)
	{
		printf("%d ", head->a);
		head = head->next;
	}
}